package org.dg.iag.server;

import java.io.File;
import java.util.Map;

import org.restlet.Request;
import org.restlet.data.MediaType;
import org.restlet.representation.FileRepresentation;
import org.restlet.representation.Representation;
import org.restlet.resource.Get;
import org.restlet.resource.ServerResource;

@Deprecated
public class HttpServerResource extends ServerResource {
	
	@Get
	public Representation serve() {
		Map<String, Object> reqAttr	= this.getRequestAttributes();
		Request req					= this.getRequest();
		String pagename	= (String)this.getRequestAttributes().get("pagename");
		FileRepresentation fp	= new FileRepresentation(
		        "webroot/" + pagename,  
		        MediaType.TEXT_HTML);
		
		return fp;
	}
	
	
	public Representation handle2() {
		Map<String, Object> reqAttr	= this.getRequestAttributes();
		String pagename	= (String)this.getRequestAttributes().get("pagename");
		File f 	= new File("webroot/"+pagename);
		String path 	= f.getAbsolutePath();
		FileRepresentation fp	= new FileRepresentation(
		        "webroot/" + pagename,  
		        MediaType.TEXT_HTML);
		
		return fp;
	}
}
